/*
 * Character.cpp
 *
 *  Created on: 25-nov.-2013
 *      Author: Axel
 */

#include "Character.h"

#include "extraMath.h"

Character::Character(double x, double y,double z, double width, double height, double speed, double angle) {
	mesh = new Mesh(x,y,z);
	this->speed = speed;
	this->angle = angle;
	dim.width = width;
	dim.height = height;

}

Character::~Character() {
	delete mesh;
}

//function the move the character
void Character::move() {
	double disx = math::cos_axel(ToRadian(angle))*speed;
	double disy = math::sin_axel(ToRadian(angle))*speed;

	mesh->move(disx, disy, 0);
}

//getter function for x
dimension Character::getDimension() {
	return dim;
}

//getter for the Mesh
Mesh* Character::getMesh() {
	return mesh;
}

//getter function for the location
Vector4f Character::getLocation() {
	return mesh->getLocation();
}

//getter function for the speed
double Character::getSpeed() {
	return speed;
}

//getter function for the angle
double Character::getAngle() {
	return angle;
}

void Character::turn(double angle) {
	this->angle += angle;
	while (angle > 360)
		angle -= 360;
	while (angle < 0)
		angle += 360;
}

void Character::render() {
	mesh->drawFigure();
}
